<?php

class MessageClass

{

	static function ShowMessage($success_msg,$success_url=null,$result = true,$fail_msg =null,$fail_url=null,$sec = NULL,$title="Message",$onTop = false)

	{

		global $GVar;
		global $Config;

		$result = empty($result)?0:1;
		if(empty($sec))
        {
			$sec = $Config->data['MessageDelay'];
        }

		$success_url = empty($success_url)?$_SERVER["HTTP_REFERER"]:$success_url;
		$success_url = empty($success_url)?$_SERVER["PHP_SELF"] . "?m=admin&t=login":$success_url;
		//$GVar->ClearCookieData();
		$GVar->session['success_msg'] = empty($success_msg)?null:$success_msg ;
        $GVar->session['title'] = empty($title)?null:$title ;
        $GVar->session['fail_msg'] = empty($fail_msg)?null:$fail_msg ;
        $GVar->session['success_url'] = empty($success_url)?null:$success_url ;
        $GVar->session['fail_url'] = empty($fail_url)?null:$fail_url ;
        $GVar->session['sec'] = $sec ;

        if(!$result)
        	$GVar->session['result'] = "0" ;
		else 
			$GVar->session['result'] = 1 ;

        $GVar->SetSessionData();

        $url="index.php?m=admin&t=ShowMessage";
        
        echo "<script>\n";
		echo "top.location.href='$url';\n";
		echo "</script>\n";
		/*if ($onTop){
			echo "<script>\n";
			echo "top.location.href='$url';\n";
			echo "</script>\n";
		}else{
			header("location:$url");
		}*/

	
		die();
	}

	static function ShowMessageComponent($success_msg,$success_url=null,$result = true,$fail_msg =null,$fail_url=null,$sec = NULL,$title="Message",$onTop = false){

		
		global $GVar;
		global $Config;

	
		$result = empty($result)?0:1;
		if(empty($sec))
        {
			$sec = $Config->data['MessageDelay'];
        }

		$success_url = empty($success_url)?$_SERVER["HTTP_REFERER"]:$success_url;
		$success_url = empty($success_url)?$_SERVER["PHP_SELF"] . "?m=admin&t=login":$success_url;
		//$GVar->ClearCookieData();
		$GVar->session['success_msg'] = empty($success_msg)?null:$success_msg ;
        $GVar->session['title'] = empty($title)?null:$title ;
        $GVar->session['fail_msg'] = empty($fail_msg)?null:$fail_msg ;
        $GVar->session['success_url'] = empty($success_url)?null:$success_url ;
        $GVar->session['fail_url'] = empty($fail_url)?null:$fail_url ;
        $GVar->session['sec'] = $sec ;

        if(!$result)
        	$GVar->session['result'] = "0" ;
		else 
			$GVar->session['result'] = 1 ;

        $GVar->SetSessionData();

        $url="/index.php?t=ShowMessageComponent";
       
        echo "<script>\n";
		echo "top.location.href='$url';\n";
		echo "</script>\n";
        
        die;
		if ($onTop){
			echo "<script>\n";
			echo "top.location.href='/index.php?t=ShowMessageComponent';\n";
			echo "</script>\n";
		}else{
			header("location:/index.php?t=ShowMessageComponent");
		}
		die();
	}
	
	
	
}
?>